﻿using System;
using System.Collections.Generic;
using System.Text;

namespace CacheAttribute.Utils
{
    public interface ICacheable
    {
        /// <summary>
        /// 泛型获取
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <returns></returns>
        T Get<T>(string key);

        /// <summary>
        /// object获取
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        object Get(string key);


        /// <summary>
        /// 设置缓存
        /// </summary>
        /// <param name="key"></param>
        /// <param name="obj"></param>
        /// <param name="Expire"></param>
        /// <returns></returns>
        bool Set(string key, object obj, int Expire = 1800);

        /// <summary>
        /// 缓存是否存在
        /// </summary>
        /// <param name="Key"></param>
        /// <returns></returns>
        bool Exist(string Key);

        /// <summary>
        /// 移除缓存
        /// </summary>
        /// <param name="Key"></param>
        /// <returns></returns>
        bool Remove(string Key);

        /// <summary>
        /// 匹配移除
        /// </summary>
        /// <param name="Pattern"></param>
        /// <returns></returns>
        bool RemovePattern(string Pattern);
    }
}
